//获取用户组
function getData(get) {
      let params = {
          page: this.page,
          limit: this.limit,
      }
      let res = get(params)
       this.total = res.count; 
       this.tables = res.data; 
    
}
//添加用户组
function createData(add) {
    this.$refs.editForm.validate(async valid => {
      if (valid) {
        let params = Object.assign({}, this.editForm)
        await add(params)
        this.$message({
          message: this.$t('public.addsuccess'),
          type: "success"
        });
        this.$refs["editForm"].resetFields(); //清空表单
        this.dialogFormVisible = false; //关闭弹窗
        this.getData(); //刷新数据
      }
    });
  }
//修改用户组 调用方法
function updateData(edit) {
    this.$refs.editForm.validate(async valid => {
      if (valid) {
        let params = Object.assign({}, this.editForm)
        await edit(params)
        this.$message({
          message: this.$t('public.editsuccess'),
          type: "success"
        });
        this.$refs["editForm"].resetFields(); //清空表单
          this.dialogFormVisible = false;
        this.getData(); //刷新数据
      }
    });
}
//删除用户组 调用方法
function handleDel(index, row, remove) {
    // 二次确认删除
    this.$confirm(this.$t('public.confirmcontent'), this.$t('public.confirmtitle'), {
      type: "warning",
    })
    .then(async () => {
      this.tables.splice(index, 1);
      let params = {
        id: row.pid,
        usid: this.$store.state.userInfo.uid
      }
      await remove(params)
      this.$message.success(this.$t('public.confirmtips1'));
      this.getData(); //刷新数据
    })
    .catch(() => {});
  }
  export default{
    getData,
    createData,
    updateData,
    handleDel
  }